package com.tmxk.days01.demo3_pets_wmh;

/**
 * 公共的父类
 *
 * @author Administrator
 */
public abstract class Pet {
    public String name;
    private int age;
    private String strain;

    public String getName() {

        return name;
    }

    public void setName(String name) {

        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if (age < 0) {
            this.age = 1;
            System.out.println("宠物年龄不能为负数,系统默认为1岁");
        } else {
            this.age = age;
        }
    }

    public String getStrain() {
        return strain;
    }

    public void setStrain(String strain) {
        this.strain = strain;
    }

    public Pet() {
        //执行父类无参构造。
    }

    public Pet(String name) {
        this.name = name;
    }

    public Pet(String name, int age, String strain) {
        super();
        this.name = name;
        this.age = age;
        this.strain = strain;
    }

    /**
     * 宠物显示基本信息的方法
     */
    public void showInfo() {
        System.out.print("宠物的基本信息:昵称是:" + this.name + ",年龄是:" + this.age +
                ",种类是: " + this.strain);
    }

    public abstract float calRent(int days);
}
